package com.varton;

import com.varton.proxy.SpentTimeInvocationHandler;
import com.varton.service.OrderSerivce;
import com.varton.service.OrderServiceImpl;

import java.lang.reflect.Proxy;

/**
 *
 * @author lihuazeng
 */
public class App {
    public static void main(String[] args) {
        /**
         *
         * 场景:在没有其他监控手段的前提下,统计查mongodb耗时,超过指定的值就打印
         */
        OrderSerivce serivce = new OrderServiceImpl();
        OrderSerivce proxyInstance = (OrderSerivce) Proxy.newProxyInstance(App.class.getClassLoader(),
                serivce.getClass().getInterfaces(), new SpentTimeInvocationHandler(serivce));
        proxyInstance.queryOrders();
    }
}